var formidable = require('formidable'),
	express = require('express');

module.exports.files = function(req, callback, setSession){
	var form = new formidable.IncomingForm();
	form.parse(req)
	form.on('field',function(name, value){
		id = req.body.fileId
	})
	form.on('fileBegin',function(name,file){
		if (file.name!='' && file.name!=null) {
			file.path = __dirname + '/public/upfiles/' + file.name
			console.log(file.name)
			callback({'status':'200'});
		} else {
			callback({'status':'503'});
		}
	})
	form.on('progress', function(bytesReceived, bytesExpected) {
		var status = parseInt(bytesReceived/bytesExpected*100);
		setSession(status)
	});
}

function fileRename(){
	
}